import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/warehouse/group_bound/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
export async function group_goods_list(params) {
  const res = await request.post('/warehouse/group_goods/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
export async function group_goods_log_list(params) {
  const res = await request.post('/warehouse/group_goods_log/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    res.data.data.row_list.forEach((item) => {
			
	  delete item.goods.indexId;
      Object.assign(item, item.goods);
    });
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 详情 */
export async function get_detail(params) {
  const res = await request.post('/material/store_group/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 待出入柜货品 */
export async function wait_goods(params) {
  const res = await request.post('/warehouse/group_bound/wait_goods', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 添加货品 */
export async function add_goods(params) {
  const res = await request.post('/warehouse/group_bound/add_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除货品 */
export async function del_goods(params) {
  const res = await request.post('/warehouse/group_bound/del_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 批量录入 */
export async function batch_enter(params) {
  const res = await request.post('/warehouse/group_bound/batch_enter', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 出入柜 */
export async function bound(params) {
  const res = await request.post('/warehouse/group_bound/bound', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 清柜 */
export async function clear_group_bound(params) {
  const res = await request.post('/warehouse/group_bound/clear', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 当前货品明细导出 */
export async function group_goods_export(params) {
  const res = await request.post('/warehouse/group_goods/export', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 领退货货品明细导出 */
export async function group_goods_log_export(params) {
  const res = await request.post('/warehouse/group_goods_log/export', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
